<template>
  <div>
    <el-form ref="formRef" :model="from" label-width="auto" style="padding-top: 20px;">
    <el-row :rules="''">
  <el-col :offset="6" :span="12" style="margin-top: 20px;">
   
       <el-form-item label="用户名" prop="username" :rules="[{ required: true, trigger: 'change', message: '用户名必填' }]">
           <el-input v-model="from.username"></el-input>
       </el-form-item>
   
  </el-col>

  <el-col :offset="6" :span="12" style="margin-top: 20px;">
   
       <el-form-item label="新密码" prop="newPassword" :rules="[{ required: true, trigger: 'change', message: '新密码必填' }]">
           <el-input v-model="from.newPassword"></el-input>
       </el-form-item>
   
  </el-col>

  <el-col :offset="6" :span="12" style="margin-top: 20px;">
    
       <el-form-item label="旧密码" prop="oldPassword" :rules="[{ required: true, trigger: 'change', message: '旧密码必填' }]">
           <el-input v-model="from.oldPassword"></el-input>
       </el-form-item>
   
  </el-col>
</el-row>
    <el-row>
          <el-col :offset="10" :span="12" style="margin-top: 20px; ">
            
                 <el-form-item >
                    <el-button type="primary"  @click='genxin()'> 更新</el-button>
                  </el-form-item>
          
          </el-col>
    </el-row>
    </el-form>
  </div>
</template>

<script lang="ts">
import {apis} from '@/api/users';
import { useinfo } from '@/store/userinfo'
export default {
  data() {
    return {
      from:{
        username:useinfo.value.username,
        newPassword:'',
        oldPassword:''
      }
      
    }
  },
  methods: {
    genxin(){
        const res = this.$refs.formRef as any
      res.validate((vali: boolean) => {
        if (!vali) return
        apis(this.from).then(res =>{
          console.log(res);
          
        })
      })
      
    }
  },
}

</script>

<style>
 .el-row {
    margin-bottom: 20px;
  
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  </style>
